package com.example.controller;

import com.example.bean.News;
import com.example.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class NewsController {

    @Autowired
    NewsService newsService;

    @RequestMapping("/getAllNews")
    @ResponseBody // 测试使用
    public String getAllNews(){
        System.out.println("正在读取新闻信息！！");
        List<News> allNews = newsService.getAllNews();

        return allNews.toString();
    }

}
